/*
 * @Author: 2112778581 2112778581@qq.com
 * @Date: 2023-10-16 10:13:29
 * @LastEditors: fengshan@0525 3183359488@qq.com
 * @LastEditTime: 2023-12-11 17:52:03
 * @FilePath: \pra\libs\db\src\models\news.model.ts
 * @Description: 轮播图entity
 */
import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop } from '@typegoose/typegoose';
import { IsNotEmpty, Allow, IsOptional } from 'class-validator';

@modelOptions({
  // 自动为每个属性添加时间戳
  schemaOptions: {
    timestamps: true,
  },
})
export class Swiper {
  @ApiProperty({ description: 'url' })
  @IsNotEmpty({ message: '图片链接不能为空' })
  @prop()
  url: string;

  @ApiProperty({ description: 'name' })
  @IsNotEmpty({ message: '展示标题为空' })
  @prop()
  name: string;

  @ApiProperty({ description: 'desc' })
  @IsNotEmpty({ message: '展示副标题为空' })
  @prop()
  desc: string;

  @ApiProperty({ description: '跳转类型' })
  @IsOptional()
  @prop()
  linkType: string; // 跳转类型 1 页面，2新闻，3产品

  @ApiProperty({ description: '跳转链接' })
  @IsOptional()
  @prop()
  toLink: string; // 跳转链接

  @ApiProperty({ description: '跳转链接' })
  @IsOptional()
  @prop()
  toLinkDetail: string; // 跳转链接文字描述（表格回显使用）

  @ApiProperty({ description: '显示排序' })
  @IsOptional()
  @prop()
  order: number;

  @ApiProperty({ description: '是否发布' })
  @IsOptional()
  @prop()
  isPublished: string

  @ApiProperty({ description: '是否显示' })
  @IsOptional()
  @prop()
  isShow: 0 | 1;

  @Allow()
  _id: string;

  @Allow()
  createdAt: string;

  @Allow()
  updatedAt: string;

  @Allow()
  __v: string;
}
